float4x4 gWorld : WORLD;
float4x4 gViewProjection : VIEWPROJECTION;
float gTime : TIME;

// The direction of the light
float4 gLightDir : DIRECTION
< string Object = "DirectionalLight"; >
= { 0, -10, 0, 0};


struct VS_INPUT
{
    float3 untransformed_pos	: POSITION0;
	float3 untransformed_norm	: NORMAL0;
};

struct VS_OUTPUT
{
    float4 transformed_pos	: SV_POSITION;
	float3 transformed_norm	: TEXCOORD0;
	float3 world_pos	: TEXCOORD1;
};

VS_OUTPUT myVertexShader(VS_INPUT input)
{
	VS_OUTPUT output;


	output.world_pos = input.untransformed_pos;
	
	float4 worldNorm = float4(input.untransformed_norm, 0.0f);
	output.transformed_norm = normalize(mul(worldNorm, gWorld));
	
	float4x4 worldViewProj = mul(gWorld, gViewProjection);
	output.transformed_pos = mul(float4(input.untransformed_pos, 1.0f), worldViewProj);


	return output; 
}

float4 myPixelShader(VS_OUTPUT input) : COLOR
{
	
	float4 diffuse = { 0.8f, 0.8f, 0.8f, 1.0f};
	return diffuse * saturate(dot(-gLightDir, input.transformed_norm));
}

technique myTechnique
{
    pass FirstPass
    {
        vertexShader = compile vs_2_0 myVertexShader();
        pixelShader  = compile ps_2_0 myPixelShader();
		ShadeMode = GOURAUD;
        //FillMode = WIREFRAME;
        CullMode = CCW;
    }
}